import json

import pytest
from AddOrganizationalManage.send_tool import Send
class TestOrganizationalManage:

    # #查询全部接口
    # def test_select_api():
    #     reponse =Send.select_fu_id()
    #     assert reponse['code'] == 0
    #     print(reponse)
    #创建组织机构接口
    @pytest.mark.parametrize("info",Send().read_yaml("add_organizational.yml"))
    def test_add_api(self,info):
        reponse =Send.select_fu_id()
        for item in info:
            item['request']["parentId"] = reponse["data"][0]["id"]
            rep = Send.add_organizational(item["request"])
            assert rep["code"] == 0
    #批量启用禁用接口
    def test_use(self):
        a=[]
        reponse = Send.select_fu_id()
        for item in reponse['data'][0]['children']:
            a.append(item["id"])
        rep= Send.use_dis(a,1)
        assert rep['code'] == 0
        rep = Send.use_dis(a, 0)
        assert rep['code'] == 0
    #编辑接口
    def test_edit(self):
        reponse = Send.select_fu_id()
        info = reponse['data'][0]['children'][0]
        rep = Send.edit_organizational(info)
        assert rep["code"] == 0
    #删除接口
    def test_delect(self):
        reponse = Send.select_fu_id()
        info = reponse['data'][0]['children']
        rep = Send.delect_organizational(info)
        assert rep["code"] == 0
    def test_big_delect(self):
        reponse = Send.select_fu_id()
        info = reponse['data'][0]['children']
        rep = Send.delect_big_organizational(info)
        assert rep["code"] == 0




